var mapIds = [993173300];
var 准备地图 = 993173350;

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("荣耀活动_塞尔提乌城墙_破坏攻城武器");
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully()
    }
    c.schedule("刷怪等待", 60 * 1000);
    c.setProperty("startTime", 0);
    c.setProperty("endTime", new Date().getTime());
    return c
}

function 刷怪等待(b) {
    b.setProperty("startTime", new Date().getTime());
    b.getPlayers().forEach(function (c) {
        c.getAPI().getWeatherEffectNotice("敌人正发动攻击！请移动至下方的大炮所在之处，并使用炮弹吧！", 297, 7000, 1);
        c.getAPI().playerMessage(5, "敌人正发动攻击！请移动至下方的大炮所在之处，并使用炮弹吧！");
        c.getAPI().cerniumMagicBombStart();
        c.getAPI().getClockCernium(1, 0, 0)
    });
    for (var a = 0; a < 20; a++) {
        b.schedule("刷怪", a * 1500)
    }
    b.schedule("刷怪停止", (10 * 3 + 4) * 1000)
}

function 刷怪(b) {
    var c = b.getMapInstance(0);
    for (var a = 0; a < b.rand(3, 6); a++) {
        c.spawnMonsterOnGroundBelow(em.getMonster(b.rand(9833641, 9833643)), new java.awt.Point(b.rand(0, 1850), -1230))
    }
}

function 刷怪停止(a) {
    a.getPlayers().forEach(function (b) {
        b.getAPI().getWeatherEffectNotice("敌人好像暂停攻击了。为应对下一轮攻击，需最大限度地收集武器。", 297, 7000, 1);
        b.getAPI().playerMessage(5, "敌人好像暂停攻击了。为应对下一轮攻击，需最大限度地收集武器。");
        b.getAPI().cerniumMagicBombStop();
        b.getAPI().getClockCernium(0, 60 * 1000, 60 * 1000)
    });
    a.schedule("刷怪等待", 60 * 1000);
    a.setProperty("endTime", new Date().getTime())
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(-100);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0))
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    em.setProperty("kill", "0");
    em.setProperty("level", "0");
    em.setProperty("clear", "0");
    em.setProperty("curMap", a);
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onMonsterDamaged(b, a, d, e, c) {}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(b, d, c) {
    var a = em.getNumberProperty("kill") + 1;
    em.setProperty("kill", a)
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
}

function onItemPickedUp(b, a, d) {
    if (d == 2630834) {
        a.removeAll(2630834);
        var c = p.getAPI().addNumberForQuestInfo(100336, "bomb", 1);
        p.getAPI().onSetSpecialAmmo(c)
    }
};